package com.wx.javacode.poly_.detail_;

/**
 * ClassName:PolyDetail02
 * Package :com.wx.javacode.poly_.detail_
 * Description :
 *
 * @Author : coder_mu
 * @Create : 2023/5/18 - 20:10
 */
public class PolyDetail02 {
    public static void main(String[] args) {
        Base base = new Sub();//向上转型，不能访问子类特有的成员
        System.out.println(base.count);//10
        Sub sub = (Sub)base;
        System.out.println(sub.count);//向下转型，属性值看类型，类型是Sub，所以输出值为20
    }
}

class Base {//父类
    int count = 10;//属性
}

class Sub extends Base {
    int count = 20;//子类属性
}
